
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
 
}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}



function clearDefault(el) {
  if (el.defaultValue==el.value) el.value = ""
}

function swapaddress() {
var myindex=form.myaddresses.selectedIndex;
if (form.myaddresses.options[myindex].value != "") {   	

var fone = form.myaddresses.options[myindex].value.split(":");


document.form.recipient_name.value = fone[0];
document.form.saddress_one.value = fone[1];
document.form.saddress_two.value = fone[2];
document.form.ssuburb.value = fone[3];
document.form.spostcode.value = fone[5];
document.form.shipping.value = fone[6];
document.form.s_time.value = fone[7];

document.form.sstate.options[0]=new Option(fone[4], fone[4], true, true);

}
else {
	alert('Please choose an Address');
}
}

function swaphosp() {
var myindex=form.hospital.selectedIndex;
if (form.hospital.options[myindex].value != "") {   	

var fone = form.hospital.options[myindex].value.split(":");


document.form.s_time.value = fone[0];
document.form.saddress_one.value = fone[1];
document.form.saddress_two.value = fone[2];
document.form.ssuburb.value = fone[3];
document.form.spostcode.value = fone[5];

document.form.sstate.options[0]=new Option(fone[4], fone[4], true, true);
ToggleHospitals();
}
else {
	alert('Please choose a hospital or click Cancel to close this window');
}
}

function ToggleHospitals() { 
if( document.getElementById("hospitals").style.display == "none" ) {
    document.getElementById("hospitals").style.display = "block"; 
     document.getElementById("hospitalbutton").style.display = "none"; 
  } else { 
    document.getElementById("hospitals").style.display = "none";
    document.getElementById("hospitalbutton").style.display = "block"; }
}

function ToggleLogin() { 
if( document.getElementById("loginpane").style.display == "none" ) {
    document.getElementById("loginpane").style.display = "block";
    document.getElementById("sdetails").style.display = "none"; 
    document.getElementById("express_login").style.display = "none"; 
    document.getElementById("extraboxes").style.display = "none"; 
  } else { 
    document.getElementById("loginpane").style.display = "none";
    document.getElementById("sdetails").style.display = "block"; 
    document.getElementById("express_login").style.display = "block"; 
    document.getElementById("extraboxes").style.display = "block"; 
 }
}

function ToggleForgot() { 
if( document.getElementById("forgotpane").style.display == "none" ) {
    document.getElementById("forgotpane").style.display = "block";
    document.getElementById("sdetails").style.display = "none"; 
    document.getElementById("express_login").style.display = "none";
    document.getElementById("extraboxes").style.display = "none";  
  } else { 
    document.getElementById("forgotpane").style.display = "none";
    document.getElementById("sdetails").style.display = "block"; 
    document.getElementById("express_login").style.display = "block";
    document.getElementById("extraboxes").style.display = "block";  
 }
}







/* Create a new XMLHttpRequest object to talk to the Web server */
var xmlHttp = false;
/* @*/
/* ( >= 5)
try {
  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
  try {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e2) {
    xmlHttp = false;
  }
}
 @*/

if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
  xmlHttp = new XMLHttpRequest();
}



function LookupPassword() {



document.getElementById('forgotpane').style.display = "none";
document.getElementById('forgotpanewait').style.display = "block";
document.getElementById('forgotpanewait').innerHTML   = "<p align='center'><img src='/images/wait.gif'></p>";


  
  

var femail = document.getElementById("Femail").value;
  if ((femail == null) || (femail == "")) {
  	
  	document.getElementById('forgotpane').style.display = "block";
  }


  // Build the URL to connect to
  var url = "/cgi-bin/cart/checkout.cgi?lookupajax=1&email=" + escape(femail);


  // Open a connection to the server
  xmlHttp.open("GET", url, true);

  // Setup a function for the server to run when it's done
  xmlHttp.onreadystatechange = DisplayLogin;

  // Send the request
  xmlHttp.send(null);
}


function DisplayLogin() {
  if (xmlHttp.readyState == 4) {
    var response = xmlHttp.responseText;
    
    if (response == "Yes") {
    
    document.getElementById('forgotpanewait').style.display = "none";
//    document.loginform.value = document.getElementById("Femail").value;
    document.getElementById('loginmessage').style.display = "block";
    document.getElementById('loginpane').style.display = "block";
 
	
    	
    }
    else {
document.getElementById('forgotpanewait').style.display = "none";    	
document.getElementById('forgotpane').style.display = "block";
document.getElementById('forgotpaneerror').style.display = "block";
    }
    

  }
}





function callServer() {
  // Get the city and state from the web form
var sstate = document.getElementById("sstate").value;
  var ssuburb = document.getElementById("ssuburb").value;
  // Only go on if there are values for both fields
  if ((ssuburb == null) || (ssuburb == "")) return;
  if ((sstate == null) || (sstate == "")) return;

  // Build the URL to connect to
  var url = "/cgi-bin/cart/postcode.cgi?postcode=" + escape(ssuburb) + "&state=" + escape(sstate);


  // Open a connection to the server
  xmlHttp.open("GET", url, true);

  // Setup a function for the server to run when it's done
  xmlHttp.onreadystatechange = updatePage;

  // Send the request
  xmlHttp.send(null);
}


function updatePage() {
  if (xmlHttp.readyState == 4) {
    var response = xmlHttp.responseText;
    
    if (response != 'Unknown') {
    
    document.getElementById("spostcode").value = response;
    }
  }
}

var wiv=null;
function ShowMessages() {

   if (wiv) wiv.close();
   wiv=window.open("/cgi-bin/cart/checkout.cgi?showmessages=1","","width=610,height=440,location=no,scrollbars=auto,status=no");
}


var wivw=null;
function ChooseDate(Datestring) {

   if (wivw) wivw.close();
   wiv=window.open(Datestring,"","width=330,height=250,location=no,scrollbars=auto,status=no");
}

